$(document).ready(function(){
  $('#ddltestsite').live('change', function() {
    if($(this).val().length != 0) {
			var id = $(this).val();
            $.ajax({
                type: 'GET',
                url: '../trainees/get_categories_ajax',
                data: "testsiteId=" + id,
				dataType:"json",
                success: populateCategoryList, context:this
            }); 
            return false;
			}
        });
		
     $('#listcategory').live('change', function() {
		var id = $("#listcategory option:selected").val();
		if(id != -1)
		{
			//var selectedText = $("#listcategory option:selected").text();
			$.ajax({
					type:'GET',
					url: '../trainees/get_subjects_ajax',
					data: "categoryId=" + id,
					success: populateSubjectList//ajax response
				});
		}
	});
 
});
 
function populateCategoryList(response, status) {
  var listItem = '<option value="-1">Select one...</option>';
  $.each(response, function(index, name) {
	// listItem += '<li value="' + index + '"><a >' + name + '</a></li>';
	listItem += '<option value="'+index+'">' + name + '</option>';
  });
  $('#listcategory').html(listItem);
  $('#categories').show();
 
}
function clkCategory(id)
{
	// if(id > 0) {
		// $.ajax({
			// type: 'GET',
			// url: '../trainees/get_subjects_ajax',
			// data: "testsiteId=" + id,
			// dataType:"json",
			// success: populateSubjectList, context:this
		// }); 
		// return false;
		// }
	$.ajax({
		type:'GET',
		url: '../trainees/get_subjects_ajax',
		data: "categoryId=" + id,
		success: populateSubjectList//ajax response
	});
}
function populateSubjectList(response, status) {
  $('#listSubject').html(response);
  $('#subjects').show();
 
}